import * as API from '../utils/api'

export const LOAD_ANNOUNCEMENT_LIST = 'LOAD_ANNOUNCEMENT_LIST'
export const UPDATE_ANNOUNCEMENT_LIST = 'UPDATE_ANNOUNCEMENT_LIST'

export const loadAnnouncementList = function ({pageNum=1}) {
    return async function (dispatch)  {
        const list = await API.fetchAnnouncementList({pageNum})
        dispatch(updateAnnouncementList({
            ...list
        }))
    }
}
export const updateAnnouncementList = list => ({type: UPDATE_ANNOUNCEMENT_LIST, list})